package com.panshi.modules.common.article;



import com.panshi.api.api.ArticleNoPort;
import com.panshi.api.bean.ArticleNoBean;
import com.panshi.api.util.CommonResult;
import com.panshi.api.util.PageSizeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author :jiege
 * @description :
 * @create :2020-08-13 10:03:00
 */
@Controller
@Api(tags = "未审核文章接口")
public class UnArticleController {

   @Autowired
    private ArticleNoPort articleNoPort;


    @GetMapping("/article/unlist")
    @RequiresPermissions("unarticle:list")
    @ApiOperation("未审核页面")
    public String unarticlepage(){
        return "/article/unarticle-list";
    }

    @GetMapping("/article/listno")
    @RequiresPermissions("unarticle:list")
    @ResponseBody
    @ApiOperation("查询所有未审核文章")
     public PageSizeVO queryallnoarticles(Integer currentPage,Integer pageSize){
        System.out.println(currentPage+"============"+pageSize);
        PageSizeVO pageSizeBean = new PageSizeVO();
        pageSizeBean.setStartIndex(currentPage);
        pageSizeBean.setPageSize(pageSize);
          return articleNoPort.queryArticleNoAll(pageSizeBean);
    }

    @PostMapping("/article/updateno")
    @ResponseBody
    @RequiresPermissions("unarticle:update")
    @ApiOperation("修改未审核文章")
    public CommonResult<String> updateunanserlist(ArticleNoBean articleNoBean){
        System.out.println("我进来了=============================================");
        System.out.println(articleNoBean);
        articleNoPort.updateAssignArticleNoInfo(articleNoBean);
        return new CommonResult<>();
    }

    @GetMapping("/article/deleteno")
    @ResponseBody
    @RequiresPermissions("unarticle:delete")
    public CommonResult<String> deleteanswerlist(Integer aid){
        articleNoPort.deleteArticleNoInfo(aid);
        return new CommonResult<>();
    }
}
